﻿#include "mainwindow.h"
#include "http/http.h"
#include "common_log.h"




MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	server = new Http("http:://127.0.0.1:8089");
	ServerInter inter = {};
	inter.name = "hello";
	inter.log = true;
	inter.callback = [](const QByteArray& req, QByteArray& ans) {
		log_trace("{}", req);
		ans = req;
	};
	server->RegisterInterface("/hellow", inter);
	
	log_trace("123");
	m_th = new std::thread(&MainWindow::RunServer, this);
	m_th->detach();
}

MainWindow::~MainWindow()
{
}
void MainWindow::RunServer()
{
	server->Start(8088);
}
void MainWindow::on_pushButton_clicked()
{
	while (1) {};
}
